﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LGSVR.Common;
using System.Data.SqlClient;
using System.Data;

namespace LGSVR.BLL.Terminal
{
    public class CardTypeBLL 
    {
        public DataTable GetAllCardType()
        {
            string sql = "select * from cardType where state=1 ";
          
            List<SqlParameter> lstParam = new List<SqlParameter>();          
            DataTable dt = SQLHelper.GetDataTable(sql, CommandType.Text, lstParam.ToArray());
          
            return dt;
        }
        public bool IsHasTypeID(string typeID, int id)        
        {
            string sql = "select count(*) from cardType where state=1 and [TypeID]=@TypeID";
            if (id != 0)
            {
                sql += " and id!=@ID";
            }
            List<SqlParameter> lstParam = new List<SqlParameter>();
            lstParam.Add(new SqlParameter("@TypeID", typeID));
            lstParam.Add(new SqlParameter("@ID", id));

            int len = Convert.ToInt32(SQLHelper.GetScale(sql, System.Data.CommandType.Text, lstParam.ToArray()));
            return len > 0;
        }
    }
}
